package com.ycfmedical.bed.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.ycfmedical.bed.R;
import com.ycfmedical.bed.adapter.HisMedicalRecordsAdapter;
import com.ycfmedical.bed.local.DataManager;
import com.ycfmedical.bed.local.entity.BillRecords;
import com.ycfmedical.bed.local.entity.User;
import com.ycfmedical.bed.present.HisMedicalRecordsPresent;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import cn.droidlover.xdroidmvp.mvp.XFragment;
import cn.droidlover.xrecyclerview.XRecyclerContentLayout;

/**
 * Created by yf on 2017-05-01.
 * 住院病例
 */

public class HisMedicalrecordsFragment extends XFragment<HisMedicalRecordsPresent> {


    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.name)
    TextView name;
    @BindView(R.id.sex)
    TextView sex;
    @BindView(R.id.age)
    TextView age;
    @BindView(R.id.bingqu)
    TextView bingQu;
    @BindView(R.id.kebie)
    TextView keBie;
    @BindView(R.id.bedID)
    TextView bedID;
    @BindView(R.id.binghao)
    TextView bingHao;
    @BindView(R.id.medicalRecords)
    XRecyclerContentLayout medicalRecords;
    Unbinder unbinder;
    HisMedicalRecordsAdapter adapter;
    @Override
    public void initData(Bundle savedInstanceState) {

        adapter=new HisMedicalRecordsAdapter(getContext());
        medicalRecords.getRecyclerView().verticalLayoutManager(getContext());
        medicalRecords.getRecyclerView().setAdapter(adapter);
        if(null!= DataManager.getInstance().getUser()){
            initExcelTitle(DataManager.getInstance().getUser());
            getP().loadData();
        }
    }

    private void initExcelTitle(User user) {
        name.setText(user.getName());
        age.setText(user.getAge() + "");
        bedID.setText(user.getBedId());
        sex.setText(user.getSex());
    }

    public void showData(List<BillRecords> billRecordsList){
        adapter.setData(billRecordsList);
        adapter.notifyDataSetChanged();
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_his_medicalrecords;
    }

    @Override
    public HisMedicalRecordsPresent newP() {
        return new HisMedicalRecordsPresent();
    }


}
